﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;

namespace WorkFlowCore.Plugins
{
    public class Plugin:AggregateRoot<Guid>
    {

        public Plugin(PluginId pluginId, string configMapInfo, string description, Guid? id=null)
        {
            if (id == null || id == Guid.Empty)
                id = Guid.NewGuid();
            PluginId= pluginId;
            Id = id.Value;
            ConfigMapInfo = configMapInfo;
            Description = description;
            FilePath = Path.Combine(pluginId.ClassName,pluginId.Name, pluginId.EntryFullName);
        }
        public Plugin()
        {
        }

        public PluginId PluginId { get; set; }
        /// <summary>
        /// 路径
        /// </summary>
        public string FilePath { get; set; }
        /// <summary>
        /// 配置字段信息i
        /// </summary>
        public string ConfigMapInfo { get; set; }
        /// <summary>
        /// 描述 说明
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 启用状态
        /// </summary>
        public bool IsEnabled { get; set; }
        /// <summary>
        /// 启用
        /// </summary>
        public void Enabled()
        {
            IsEnabled = true;
        }
        /// <summary>
        /// 禁用
        /// </summary>
        public void Disabled()
        {
            IsEnabled = false;
        }
        /// <summary>
        /// 获取插件的文件路径
        /// </summary>
        /// <param name="basePath"></param>
        /// <returns></returns>
        public string GetFilePath(string basePath)
        {
            return Path.Combine(basePath,"CustomerPlugins", FilePath);
        }
    }
}
